/**
 * Copyright 2019 [shujiang.yang], Inc. All rights reserved.
 * Email: 314938230@qq.com
**/
define("pages/bgcl/bgcl_main", [
        "../../common/componts.js",
        "../../plugins/easyui/jquery-easyui-1.5.1/jquery.easyui.min",
        "../../plugins/easyui/jquery-easyui-1.5.1/easyloader",
        "../../plugins/artTemplate/artTemplate"
    ],
    function(require) {
        var drawGraph = function(){
            var user_permission = 2 ; 	//设置获取到的用户权限
            var rsdj_permission = 2 ;	//设置出所管理需要的权限
            var container = document.getElementById("main");
            var graph = new mxGraph(container);
            var parent = graph.getDefaultParent();

            graph.setHtmlLabels(true);

            graph.setEnabled(false);

            var style = {};

            style = graph.getStylesheet().getDefaultEdgeStyle();//圆角连线
            style[mxConstants.STYLE_ROUNDED] = true;//圆角连线
            style = mxUtils.clone(style);
            style[mxConstants.STYLE_SHAPE] = mxConstants.SHAPE_LABEL;  // 不设置这个属性 背景图片不出来

            style[mxConstants.STYLE_STROKECOLOR] = '#f5f5f5';

            style[mxConstants.STYLE_FILLCOLOR] = '#f5f5f5';

            style[mxConstants.STYLE_FONTCOLOR] = 'black';

            style[mxConstants.STYLE_ALIGN] = mxConstants.ALIGN_CENTER;

            style[mxConstants.STYLE_VERTICAL_ALIGN] = mxConstants.ALIGN_BOTTOM;

            style[mxConstants.STYLE_FONTSIZE] = 13;

            style[mxConstants.STYLE_IMAGE_ALIGN] = 0;

            style[mxConstants.STYLE_IMAGE_VERTICAL_ALIGN] = 0;

            style[mxConstants.STYLE_IMAGE] = '../../img/lcttx.png';

            style[mxConstants.STYLE_IMAGE_WIDTH] = 80;

            style[mxConstants.STYLE_IMAGE_HEIGHT] = 80;

            style[mxConstants.STYLE_SPACING_TOP] = 30;

            style[mxConstants.STYLE_SPACING] = 0.5;

            graph.getStylesheet().putCellStyle("style1", style);

            var style2 = {};

            style2 = graph.getStylesheet().getDefaultEdgeStyle();//圆角连线
            style2[mxConstants.STYLE_ROUNDED] = true;//圆角连线
            style2 = mxUtils.clone(style);
            style2[mxConstants.STYLE_SHAPE] = mxConstants.SHAPE_LABEL;  // 不设置这个属性 背景图片不出来

            style2[mxConstants.STYLE_STROKECOLOR] = '#f5f5f5';

            style2[mxConstants.STYLE_FILLCOLOR] = '#f5f5f5';

            style2[mxConstants.STYLE_FONTCOLOR] = 'black';

            style2[mxConstants.STYLE_ALIGN] = mxConstants.ALIGN_CENTER;

            style2[mxConstants.STYLE_VERTICAL_ALIGN] = mxConstants.ALIGN_BOTTOM;

            style2[mxConstants.STYLE_FONTSIZE] = 13;

            style2[mxConstants.STYLE_IMAGE_ALIGN] = 0;

            style2[mxConstants.STYLE_IMAGE_VERTICAL_ALIGN] = 0;

            style2[mxConstants.STYLE_IMAGE] = '../../img/zh.png';

            style2[mxConstants.STYLE_IMAGE_WIDTH] = 80;

            style2[mxConstants.STYLE_IMAGE_HEIGHT] = 80;

            style2[mxConstants.STYLE_SPACING_TOP] = 30;

            style2[mxConstants.STYLE_SPACING] = 0.5;

            graph.getStylesheet().putCellStyle("style2", style2);




            //获取流程节点的待办数量
            var jbdjCount=0;
            var jbqrCount=0;



            // 画人物
            var v1 = graph.insertVertex(parent, 'gjjd', '管教鉴定<font color="jbdj"></font>', 200, 220, 100, 105, "style1");

            var v2 = graph.insertVertex(parent, 'jzyj', '警组意见<font color="jbqr"></font>', 400, 220, 100, 105, "style1");

            var v3 = graph.insertVertex(parent, 'szyj', '所长意见<font color="jbqr"></font>', 600, 220, 100, 105, "style1");

            var v4 = graph.insertVertex(parent, 'kzdy', '开证打印<font color="jbqr"></font>', 800, 220, 100, 105, "style1");
            var v5 = graph.insertVertex(parent, 'cwfh', '财物返还<font color="jbqr"></font>', 800, 350, 100, 105, "style1");

            var v6 = graph.insertVertex(parent, 'ls', '离所<font color="jbqr"></font>', 1000, 220, 100, 105, "style1");


            // 连线
            graph.insertEdge(parent, null, '',v1, v2 , "edgeStyle=elbowEdgeStyle;");
            graph.insertEdge(parent, null, '',v2, v3 , "edgeStyle=elbowEdgeStyle;");
            graph.insertEdge(parent, null, '',v3, v4 , "edgeStyle=elbowEdgeStyle;");
            graph.insertEdge(parent, null, '',v3, v5 , "edgeStyle=elbowEdgeStyle;");
            graph.insertEdge(parent, null, '',v4, v6 , "edgeStyle=elbowEdgeStyle;");

            //添加事件
            graph.addListener(mxEvent.CLICK, function(sender, evt) {
                var cell11 = evt.getProperty('cell');
                //graph.setCellStyles(fillColor,black);
                if(cell11==null){
                    $("#pictureId").css({"display":"none"});
                    return ;
                }else if(cell11.id=='gjjd'){// 管教鉴定
                    window.location.href='/bgcl/bgcl_jbxx_enter.html?processDefinitionKey=kss_bgcl&taskDefinitionKey=kss_bgcl_gjjd';
                }else if (cell11.id=='jzyj'){// 警组意见
                    window.location.href='/bgclJzcl/bgclJzcl_jbxx_enter.html?processDefinitionKey=kss_bgcl&taskDefinitionKey=kss_bgcl_jzyj';
                }else if(cell11.id=='szyj'){// 所长意见
                    window.location.href='/bgclSzyj/bgclSzyj_jbxx_enter.html?processDefinitionKey=kss_bgcl&taskDefinitionKey=kss_bgcl_szyj';
                }else if(cell11.id=='kzdy'){// 开证打印
                    window.location.href='/bgclKzdy/bgclKzdy_jbxx_enter.html?processDefinitionKey=kss_bgcl&taskDefinitionKey=kss_bgcl_kzdy';
                }else if(cell11.id=='cwfh'){// 财物返还
                    window.location.href='/bgclCwfh/bgclCwfh_jbxx_enter.html?processDefinitionKey=kss_bgcl&taskDefinitionKey=kss_bgcl_cwfh';
                }else if(cell11.id=='ls'){// 离所
                    window.location.href='/bgclLs/bgclLs_jbxx_enter.html?processDefinitionKey=kss_bgcl&taskDefinitionKey=kss_bgcl_ls';
                }
            });
            //鼠标悬浮效果
            var track = new mxCellTracker(graph);
            var self = this;
            track.mouseMove = function(sender, me) {
                var cell1 = this.getCell(me);
                if(cell1==null){
                    $("#pictureId").css({"display":"none"});
                    return ;
                }else{
                    if(cell1.id=="tscldj"){
                        $("#pictureId").css({"display":"block","left":"250px","top":"170px"});
                        $("#pictureId").html("投诉处理登记登记！");
                    }else if (cell1.id=="ldsp"){
                        $("#pictureId").css({"display":"block","left":"550px","top":"170px"});
                        $("#pictureId").html("领导审批！");
                    }else if (cell1.id=="cldjcljg"){
                        $("#pictureId").css({"display":"block","left":"850px","top":"170px"});
                        $("#pictureId").html("登记处理结果！");
                    }
                }
            };
            //
            function bodyScale(){
                var main = document.getElementById("main"); //获取id="main"
                var devicewidth=document.documentElement.clientWidth;
                var scale=devicewidth/1275;//除去当前流量器分辨率1275
                main.style.zoom=scale;//zoom是设置或检索对象的缩放比例.
            }
            window.onload=window.onresize=function(){
                bodyScale();
            }
            //自适应任何设备屏幕
            function bodyScale(){
                var main = document.getElementById("main"); //获取id="main"
                var devicewidth=document.documentElement.clientWidth;
                var scale=devicewidth/1275;//除去当前流量器分辨率1275
                main.style.zoom=scale;//zoom是设置或检索对象的缩放比例.
            }
            window.onload=window.onresize=function(){
                bodyScale();
            }
        }

        drawGraph();
    }
)
